package com.huarui.inventory.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.ewaf.framework.action.BaseAction;
import com.huarui.inventory.service.InventoryService;
import com.huarui.params.Params;
import com.huarui.user.model.SessionMessage;
import com.huarui.user.security.UserHolder;

public class InventoryToSaleActon extends BaseAction{

	public static final String MESS = "mess";
	
	private static final long serialVersionUID = -1048330031295837005L;

	private static final Logger log = Logger.getLogger(InventoryToSaleActon.class);
	private InventoryService inventoryService;
	
	private Integer start;
	
	private Integer limit;
	
	private Map<String, Object> mesMap;
	
	private String queryParam;
	
	public Integer getStart() {
		return start;
	}


	public void setStart(Integer start) {
		this.start = start;
	}


	public Map<String, Object> getMesMap() {
		return mesMap;
	}


	public void setMesMap(Map<String, Object> mesMap) {
		this.mesMap = mesMap;
	}


	public void setInventoryService(InventoryService inventoryService) {
		this.inventoryService = inventoryService;
	}

	public void setQueryParam(String queryParam) {
		this.queryParam = queryParam;
	}
	
	public String showInventoryToSale() {
		Map<String, Object> paramsMap = new HashMap<String, Object>();
		paramsMap.put("start", start == null ? 0 : start);
		paramsMap.put("pageSize", Params.PAGE_SIZE);
		
		SessionMessage sm = UserHolder.getCurrentSessionMessage();
		Integer sellerId = sm.getCompanyId();
		paramsMap.put("sellerId", sellerId);
		
		mesMap = this.inventoryService.showInventoryToSale(paramsMap);
		return MESS;
	}
	
	
	public String pickInventoryToSale(){		
		mesMap = new HashMap<String, Object>();
		try {
			mesMap = inventoryService.pickInventoryToSale(queryParam,start,limit);
			mesMap.put("success", true);		
		} catch (Exception e) {
			log.error("查询零件库存失败....", e);
			mesMap.put("success", false);
			mesMap.put("msg","查询零件库存失败...." );
		}
		return SUCCESS;
	}


	public void setLimit(Integer limit) {
		this.limit = limit;
	}


	public Integer getLimit() {
		return limit;
	}


	
}
